﻿#pragma once
#include "base.h"
#include "Quote.h"


struct MainIns
{
	int	id;		//自定义编号
	FStringW szCN;	//显示名
	FStringW szEN;	//合约ID
	
};

typedef_vector(MainIns, _main_ins);

class createDeviceApp : public IFApplication, public IQuoteEvent
{
	FDECLARE_CLASS(createDeviceApp);
public:
	FIDFONT fnt_id;             // 自定义字体ID
	FIDTEXTURE tex_id;
	float sprx, spry;	
	CThostFtdcMdApi *	pMDApi;
	CQuoteProtocol      protocol;
	int					nRequestID;
	FFString			szInsA;
	FFString			szInsB;
	FUI_System uiSys;
	Quote myWnd;
//	tagIns insA;
//	tagIns insB;
	fv_main_ins			mainIns;
	FStringA			szImei;
	
public:
	createDeviceApp();
	virtual bool Create();
	virtual void Destroy();
	virtual void Render();
	virtual bool OnInput(FINPUT_PACKAGE& ipk);	
	virtual void Update();
	
	/*
		Impl
	*/
	virtual void OnFrontConnected();
	virtual void OnFrontDisconnected(int nReason);
	virtual void OnHeartBeatWarning(int nTimeLapse);
	virtual void OnRspUserLogin(CThostFtdcRspUserLoginField *pRspUserLogin, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
	virtual void OnRspUserLogout(CThostFtdcUserLogoutField *pUserLogout, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
	virtual void OnRspError(CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
	virtual void OnRspSubMarketData(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
	virtual void OnRspUnSubMarketData(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
	virtual void OnRspSubForQuoteRsp(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
	virtual void OnRspUnSubForQuoteRsp(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
	virtual void OnRtnDepthMarketData(CThostFtdcDepthMarketDataField *pDepthMarketData);
	virtual void OnRtnForQuoteRsp(CThostFtdcForQuoteRspField *pForQuoteRsp);
	
	/*
		下载main_ins.xml
	*/
	void GetMainInsText();
	int GetID(char *szIns);
	FFString GetCNName(char *szIns);

	/*
		java imple
	*/
	void OnIMEI(FStringA imei){ szImei = imei; }
};